package com.jwdf.uda.http.action;

import android.content.Context;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.http.AHttpService;
import com.jwdf.uda.http.ApiService;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;

/**
 * Created by Administrator on 2016/6/16.
 */
public class UserReadMessageAction extends AHttpService<PbBean.PbResUserReadMessage> {

    private List<Integer> messageList;
    private int messageId;
    private boolean readAll;

    public static UserReadMessageAction newInstance(Context context) {
        return new UserReadMessageAction(context);
    }

    public static UserReadMessageAction newInstance(Context context, int messageId) {
        return new UserReadMessageAction(context, messageId);
    }

    private UserReadMessageAction(Context context) {
        super(context);
        this.messageList = new ArrayList<>();
        this.readAll=true;
    }

    private UserReadMessageAction(Context context, int messageId) {
        super(context);
        this.messageId = messageId;
    }

    @Override
    protected Call newRetrofitCall(ApiService apiService, PbBean.PbBaseClientInfo.Builder baseBuilder) {
        PbBean.PbReqUserReadMessage.Builder builder = PbBean.PbReqUserReadMessage.newBuilder();
        builder.setBaseClientInfo(baseBuilder);
        if (messageList != null) {
            builder.addAllMessageIdList(messageList);
        } else {
            builder.addMessageIdList(messageId);
        }
        builder.setIsReadAll(readAll);

        return apiService.readMessageList(builder.build());
    }
}
